INtime SDK Help
snprintf, snprintf_n, _snwprintf

 Prints formatted data to a string while limiting the maximum number of characters to produce.

#include <stdio.h>

int snprintf(char *buffer, size_t size, const char *format[, argument]...);
int snprintf_s(char *buffer, rsize_t size, const char *format[, argument]...);

Parameters

buffer
Output buffer.
size
The size of the storage location at buffer, in characters. Size in chars for snprintf or size in wchar_ts for the wide-character functions.
format
Formatted string consisting of ordinary characters, escape sequences, and, if arguments appear, format specifications. The format and optional arguments have the same form and function as printf.
argument
Optional arguments.

Return Values

Let len be the length of the formatted data string, not including the terminating null. len and size are in bytes for _snprintf, wchar_t for _snwprintf.

If len < size, len characters are stored in buffer, a null-terminator is appended, and len is returned.

snprintf and snprintf_s differ in the way that they handle overflow. In the case of snprintf and _snwprintf:

In the case of snwprintf_s, if the storage required to store the data and a terminating null exceeds size, the functions set buffer to an empty string, errno is set to ERANGE, and return -1. If buffer or format is a NULL pointer, or if size is less than or equal to zero, these functions set errno to EINVAL and return -1.

Remarks

The ordinary characters and escape sequences are copied to buffer in order of their appearance.

Requirements

Versions Defined in Include Link to
INtime 3.0 intime/rt/include/stdio.h stdio.h clib.lib
See Also